﻿Imports System.ServiceModel

' HINWEIS: Mit dem Befehl "Umbenennen" im Kontextmenü können Sie den Schnittstellennamen "IMandeBackYardService" sowohl im Code als auch in der Konfigurationsdatei ändern.
<ServiceContract()>
Public Interface IBackYardService

    <OperationContract>
    Function DownloadFile(request As DownloadRequest) As RemoteFileInfo

    <OperationContract>
    Sub UploadFile(ByVal request As RemoteFileInfo)

    <OperationContract>
    Function GetOperationStatus() As OperationStatus

    <OperationContract>
    Function DeleteBackYardFile(ByVal filename As String) As Boolean

    <OperationContract>
    Function EnumerateFiles() As List(Of System.IO.FileInfo)


End Interface

<MessageContract> _
Public Class DownloadRequest
    <MessageBodyMember> _
    Public FileName As String
End Class

<MessageContract>
Public Class OperationStatus
    <MessageBodyMember>
    Public Errors As Exception

    <MessageBodyMember>
    Public HasError As Boolean

    <MessageBodyMember>
    Public OperationsType As String

End Class

<MessageContract> _
Public Class RemoteFileInfo
    Implements IDisposable

    <MessageHeader(MustUnderstand:=True)> _
    Public FileName As String

    <MessageHeader(MustUnderstand:=True)> _
    Public Length As Long

    <MessageHeader(MustUnderstand:=True)>
    Public Property OnDelete As Boolean = False

    <MessageBodyMember(Order:=1)> _
    Public FileByteStream As System.IO.Stream

    Public Sub Dispose() Implements IDisposable.Dispose
        If FileByteStream IsNot Nothing Then
            FileByteStream.Close()
            FileByteStream = Nothing
        End If
    End Sub
End Class